// import { fetchEventSource } from '@microsoft/fetch-event-source';
const fetchEventSource = require('@microsoft/fetch-event-source')

const ctrl = new AbortController();
fetchEventSource('http://127.0.0.1:8000/adh/agent/v0/infer', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({"engine":"AliAgent","data":"介绍一下自己","streaming":true,"settings":{"url":"","key":""}}),
    signal: ctrl.signal,
    onmessage(ev) {
        if (ev.data === '[DONE]') {
            ctrl.abort();
        }
        console.log(ev.data);
    }
});